import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { VersioningType } from '@nestjs/common';
import * as session from 'express-session';
import * as cors from 'cors';
import {Request ,Response,NextFunction} from "express";

const whiterList = ['/list'];
function middleware(req:Request, res:Response, next:NextFunction) {
  if(whiterList.includes(req.originalUrl)){
    next()
  }else {
    res.send('ggg')
  }
}
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.enableVersioning({
    type: VersioningType.URI,
  });
  app.use(cors())
  app.use(middleware)
  app.use(
    session({
      cookie: {
        maxAge: 60000,
      },
      name: 'qiangsheng.id',
      proxy: false,
      resave: false,
      rolling: true,
      saveUninitialized: false,
      secret: 'qiangsheng',
      store: undefined,
      unset: undefined,
    }),
  );
  await app.listen(3000);
}
bootstrap();
